//
// Created by 11510 on 2024/6/20.
//
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

template<class T>
T add(T t1, T t2) {
    return t1 + t2;
}

/**
 * 特化模板
 * @param s1
 * @param s2
 * @return
 */
template<>
const char* add<const char*>(const char* s1, const char* s2){
    char* p = (char*)malloc(sizeof(char) * (strlen(s1) + strlen(s2)));
    strcpy(p, s1);
    strcat(p, s2);

    return p;
}


int main(){
    const char* s1 = "123";
    const char* s2 = "456";
    const char* p = add(s1, s2);
    cout << p  << endl;

    return 0;
}